package oocl.ita.eordering.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import oocl.ita.eordering.po.Order;
import oocl.ita.eordering.service.OrderService;
import oocl.ita.eordering.vo.Result;
import oocl.ita.eordering.webService.GetOrderStatusWS;

@Controller
@RequestMapping()
public class WebServiceController {
	GetOrderStatusWS getOrderStatusWS = new GetOrderStatusWS();
	@Autowired(required = true)
	private OrderService orderService;

	// 提供A端通过oId查询complaint信息的接口
	@RequestMapping("/complaintByOId")
	@ResponseBody
	public Order complaintByOIdForAdmin(Integer oId) {
		Order order = new Order();
		order = orderService.showOrderByOrderId(oId);
		// System.out.println(order.getComplaint());
		return order;
	}

	// 提供去A端搜索complaint状态的接口
	@RequestMapping("/action/complaintStatusByOId")
	@ResponseBody
	public Result complaintStatusByOId(int oId) {
		Integer cStatus = getOrderStatusWS.getOrderStatusWS(oId);
		Result result = new Result();
		String msg = "默认未处理";
		if (cStatus != null) {
			switch (cStatus) {
			case 1:
				msg = "默认未处理";
				break;

			case 2:
				msg = "驳回投诉";
				break;
			case 3:
				msg = "扣除押金";
				break;
			case 4:
				msg = "拉黑商家";
				break;
			default:
				msg = "状态未知";
				break;
			}
			result.success(msg);
		} else {
			result.fail("系统错误");
		}
		return result;

	}
}
